# -*- coding: UTF-8 -*-
# 插入排序

def inser_sort(alist):
    for index in range(1, len(alist)):
        currentvalue = alist[index]
        position = index

        while position > 0 and alist[position-1] > currentvalue:
            alist[position] = alist[position-1]
            position = position-1

        alist[position] = currentvalue
    return alist

def insert(list):
    for i in range(1, len(list)):
        cur = i
        while cur >= 1 and list[cur-1] > list[cur]:
            list[cur-1], list[cur] = list[cur], list[cur-1]
            cur -= 1

    return list

list = [54, 26, 93, 17, 77, 3, 31, 44, 55, 20]
print(insert(list))